import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

/* Layout */
import Layout from "@/layout";

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: "/login",
    component: () => import("@/views/login/index"),
    hidden: true,
  },

  {
    path: "/404",
    component: () => import("@/views/404"),
    hidden: true,
  },

  {
    path: "/",
    component: Layout,
    redirect: "/dashboard",
    children: [
      {
        path: "dashboard",
        name: "Dashboard",
        component: () => import("@/views/dashboard/index"),
        meta: { title: "首页", icon: "dashboard" },
      },
    ],
  },

  {
    path: "/example",
    component: Layout,
    redirect: "/example/table",
    name: "Example",
    meta: { title: "APP用户管理", icon: "el-icon-s-help" },
    children: [
      {
        path: "table",
        name: "Table",
        component: () => import("@/views/table/index"),
        meta: { title: "APP用户管理", icon: "table" },
      },
    ],
  },
  {
    path: "/product",
    component: Layout,
    redirect: "/product/index",
    name: "Example",
    meta: { title: "产品管理", icon: "el-icon-s-help" },
    children: [
      {
        path: "product",
        name: "Product",
        component: () => import("@/views/product/index"),
        meta: { title: "产品管理", icon: "table" },
      },
    ],
  },
  {
    path: "/tree",
    component: Layout,
    redirect: "/tree/index",
    name: "Example",
    meta: { title: "ai托管订单", icon: "el-icon-s-help" },
    children: [
      {
        path: "index",
        name: "index",
        component: () => import("@/views/tree/index"),
        meta: { title: "ai托管订单", icon: "table" },
      },
    ],
  },
  {
    path: "/nested",
    component: Layout,
    redirect: "/nested/index",
    name: "Example",
    meta: { title: "团队业绩", icon: "el-icon-s-help" },
    children: [
      {
        path: "index",
        name: "index",
        component: () => import("@/views/nested/index"),
        meta: { title: "团队业绩", icon: "table" },
      },
    ],
  },
  {
    path: "/jlff",
    component: Layout,
    redirect: "/jlff",
    name: "jlff",
    meta: { title: "AI托管购买记录", icon: "el-icon-s-comment" },
    children: [
      {
        path: "/jlff",
        name: "jlff",
        component: () => import("@/views/jlff/index"),
        meta: { title: "AI托管购买记录", icon: "el-icon-s-comment" },
      },
    ],
  },
  {
    path: "/community",
    component: Layout,
    redirect: "/community/index",
    name: "Example",
    meta: { title: "充值管理", icon: "el-icon-s-comment" },
    children: [
      {
        path: "table",
        name: "Table",
        component: () => import("@/views/community/index"),
        meta: { title: "充值管理", icon: "el-icon-s-comment" },
      },
    ],
  },
  {
    path: "/userManage",
    component: Layout,
    redirect: "/userManage/index",
    name: "userManage",
    meta: { title: "用户管理", icon: "el-icon-s-comment" },
    children: [
      {
        path: "table",
        name: "Table",
        component: () => import("@/views/userManage/index"),
        meta: {
          title: "后台用户列表",
          icon: "el-icon-s-custom",
        },
      },
      // 404 page must be placed at the end !!!
    ],
  },
  {
    path: "/order",
    component: Layout,
    redirect: "/order/index",
    name: "Example",
    meta: { title: "转账列表", icon: "el-icon-s-order" },
    children: [
      {
        path: "table",
        name: "Table",
        component: () => import("@/views/order/index"),
        meta: { title: "转账列表", icon: "el-icon-s-order" },
      },
    ],
  },
  {
    path: "/form",
    component: Layout,
    redirect: "/form/index",
    name: "Example",
    meta: { title: "提现管理", icon: "el-icon-s-comment" },
    children: [
      {
        path: "form",
        name: "form",
        component: () => import("@/views/form/index"),
        meta: { title: "提现管理", icon: "el-icon-s-comment" },
      },
    ],
  },
  // {
  //   path: "/news",
  //   component: Layout,
  //   redirect: "/news/index",
  //   name: "Example",
  //   meta: { title: "系统公告管理", icon: "el-icon-s-comment" },
  //   children: [
  //     {
  //       path: "news",
  //       name: "news",
  //       component: () => import("@/views/news/index"),
  //       meta: { title: "系统公告管理", icon: "el-icon-s-comment" },
  //     },
  //   ],
  // },
  // {
  //   path: "/bet",
  //   component: Layout,
  //   redirect: "/bet/bet",
  //   name: "Bet",
  //   meta: { title: "下注管理", icon: "el-icon-s-comment" },
  //   children: [
  //     {
  //       path: "bet",
  //       name: "bet",
  //       component: () => import("@/views/bet/index"),
  //       meta: { title: "下注管理", icon: "el-icon-s-comment" },
  //     },
  //   ],
  // },
  // {
  //   path: "/block",
  //   component: Layout,
  //   redirect: "/blockIndex",
  //   name: "Block",
  //   meta: { title: "区块管理", icon: "el-icon-s-comment" },
  //   children: [
  //     {
  //       path: "/blockIndex",
  //       name: "blockIndex",
  //       component: () => import("@/views/block/index"),
  //       meta: { title: "区块管理", icon: "el-icon-s-comment" },
  //     },
  //   ],
  // },
  {
    path: "/bill",
    component: Layout,
    redirect: "/billIndex",
    name: "bill",
    meta: { title: "用户账单管理", icon: "el-icon-s-comment" },
    children: [
      {
        path: "/billIndex",
        name: "billIndex",
        component: () => import("@/views/bill/index"),
        meta: { title: "用户账单管理", icon: "el-icon-s-comment" },
      },
    ],
  },
  {
    path: "/config",
    component: Layout,
    redirect: "/config",
    name: "config",
    meta: { title: "系统常量管理", icon: "el-icon-s-comment" },
    children: [
      {
        path: "/config",
        name: "config",
        component: () => import("@/views/config/index"),
        meta: { title: "系统常量管理", icon: "el-icon-s-comment" },
      },
    ],
  },
  {
    path: "/adminUser",
    component: Layout,
    redirect: "/adminUser",
    name: "adminUser",
    meta: { title: "管理端用户管理", icon: "el-icon-s-comment" },
    children: [
      {
        path: "/adminUser",
        name: "adminUser",
        component: () => import("@/views/adminUser/index"),
        meta: { title: "管理端用户管理", icon: "el-icon-s-comment" },
      },
    ],
  },

  // {
  //   path: "/socketUser",
  //   component: Layout,
  //   redirect: "/socketUser/index",
  //   name: "Example",
  //   meta: { title: "强杀", icon: "el-icon-s-comment" },
  //   children: [
  //     {
  //       path: "socketUser",
  //       name: "socketUser",
  //       component: () => import("@/views/socketUser/index"),
  //       meta: { title: "强杀", icon: "el-icon-s-comment" },
  //     },
  //   ],
  // },
  {
    path: "/advice",
    component: Layout,
    redirect: "/adminAd",
    name: "Example",
    meta: { title: "咨询管理", icon: "el-icon-s-comment" },
    children: [
      {
        path: "adminAd",
        name: "adminAd",
        component: () => import("@/views/advice/index.vue"),
        meta: { title: "咨询管理" },
      },
    ],
  },
  {
    path: "/notice",
    component: Layout,
    redirect: "/notice",
    name: "Example",
    meta: { title: "通知管理", icon: "el-icon-s-comment" },
    children: [
      {
        path: "notice",
        name: "notice",
        component: () => import("@/views/notice/index.vue"),
        meta: { title: "通知管理" },
      },
    ],
  },
  {
    path: "/auth",
    component: Layout,
    redirect: "/auth",
    name: "Example",
    meta: { title: "认证管理", icon: "el-icon-s-comment" },
    children: [
      {
        path: "auth",
        name: "auth",
        component: () => import("@/views/auth/index.vue"),
        meta: { title: "认证管理" },
      },
    ],
  },
  {
    path: "/rtg",
    component: Layout,
    redirect: "/rtg",
    name: "Example",
    meta: { title: "实名认证", icon: "el-icon-s-comment" },
    children: [
      {
        path: "rtg",
        name: "rtg",
        component: () => import("@/views/authname/index.vue"),
        meta: { title: "实名认证" },
      },
    ],
  },
  {
    path: "/qa",
    component: Layout,
    redirect: "/auth",
    name: "Example",
    meta: { title: "问答管理", icon: "el-icon-s-comment" },
    children: [
      {
        path: "qa",
        name: "qa",
        component: () => import("@/views/QA/index.vue"),
        meta: { title: "问答管理" },
      },
    ],
  },
  {
    path: "/banner",
    component: Layout,
    redirect: "/banner",
    name: "Example",
    meta: { title: "banner", icon: "el-icon-s-comment" },
    children: [
      {
        path: "banner",
        name: "banner",
        component: () => import("@/views/banner/index.vue"),
        meta: { title: "banner" },
      },
    ],
  },
];
const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes,
  });

const router = createRouter();

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}

export default router;
